package com.yao.club.controller;

import com.yao.club.entity.result.ResponseEntity;
import com.yao.club.service.UserService;
import com.yao.club.token.PassToken;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/app/sms")
@Api(value = "短信验证码接口", description = "该模块提供用户短信验证码接口服务", tags = "短信验证码模块")
public class SmsController {

    @Autowired
    UserService userService;
    @PassToken
    @ApiOperation(value = "发送登陆验证码方法", notes = "发送登陆验证码方法", httpMethod = "POST")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(dataType = "String", name = "phone", value = "手机号", required = true),
            @ApiImplicitParam(dataType = "String", name = "operatorType", value = "类型:2", required = true)
    })
    @PostMapping("/sendLoginCode")
    public ResponseEntity<Boolean> sendLoginCode(String phone, String operatorType){
        return userService.sendLoginCode(phone);
    }

    @PassToken
    @ApiOperation(value = "发送忘记密码验证码方法", notes = "发送忘记密码验证码方法", httpMethod = "POST")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(dataType = "String", name = "phone", value = "手机号", required = true),
            @ApiImplicitParam(dataType = "String", name = "operatorType", value = "类型:2", required = true)
    })
    @PostMapping("/sendForgetPwdCode")
    public ResponseEntity<Boolean> sendForgetPwdCode(String phone, String operatorType){
        return userService.sendForgetPwdCode(phone);
    }


}
